﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.Entity;
using ClassLibrary.DAO;
using ClassLibrary.Data;
using CrystalDecisions.CrystalReports.Engine;

public partial class UserControl_ucReport : System.Web.UI.UserControl
{
    ReportDocument _objReport = new ReportDocument();
    TblJobsDAO JobDAO = new TblJobsDAO(Global.CONNECTION_STRING);   
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadReports();
        }
    }

    private void LoadReports()
    {
        try
        {
            _objReport.Load(Request.PhysicalApplicationPath + "Admin\\Reports\\rpServiceAgreement_Customer.rpt");
            _objReport.SetDataSource(JobDAO.reportJob1(Convert.ToInt32(Request.QueryString["id"])));

            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            CrystalReportViewer1.DisplayGroupTree = false;
            CrystalReportViewer1.EnableParameterPrompt = false;
            CrystalReportViewer1.BestFitPage = true;
            CrystalReportViewer1.ReportSource = _objReport;
            CrystalReportViewer1.DataBind();
        }
        catch (Exception ex)
        {
            Session[Global.SESSION_ERROR] = ex;
            Response.Redirect(Global.ERROR_PAGE);
        }
    }
    protected void Page_Unload(object sender, EventArgs e)
    {
        _objReport.Dispose();
        _objReport.Close();
        _objReport = null;
    }
}
